﻿using Microsoft.SharePoint;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HideRibbonItems.Layouts.HideRibbonItems
{
    public class RibbonLibraryItem
    {
        StringBuilder documentsText = new StringBuilder();
        string ribbonItemsText = string.Empty;
        string groupText = string.Empty;

        string documentsTextString = string.Empty;
        string ribbonItemsTextString = string.Empty;
        string groupTextString = string.Empty;

        public ArrayList Documents { get; set; }
        public ArrayList RibbonItems { get; set; }
        public ArrayList Groups { get; set; }

        public string DocumentsText
        {
            get
            {
                documentsText = new StringBuilder();
                int i = 1;
                foreach (string text in Documents)
                {
                    SPList list = SPContext.Current.Web.Lists[text];
                    if (list != null)
                    {
                        documentsText.AppendFormat("<a href='{0}' target='_blank'>{1}</a>", list.ParentWeb.Url +"/" + list.RootFolder.Url, text);
                    }
                    else
                    {
                        documentsText.Append(text);
                    }
                    if (i++ != Documents.Count)
                    {
                        documentsText.Append("<br/>");
                    }
                }
                return documentsText.ToString();
            }
        }

        public string DocumentsTextString
        {
            get
            {
                int i = 1;
                foreach (string text in Documents)
                {
                    documentsTextString += text;
                    if (i++ != Documents.Count)
                    {
                        documentsTextString += ",";
                    }
                }
                return documentsTextString;
            }
        }
        public string RibbonItemsText
        {
            get
            {
                int i = 1;
                ribbonItemsText = "";
                foreach (string text in RibbonItems)
                {
                    ribbonItemsText += text;
                    if (i++ != RibbonItems.Count)
                    {
                        ribbonItemsText += "<br/>";
                    }
                }
                return ribbonItemsText;
            }
        }
        public string RibbonItemsTextString
        {
            get
            {
                int i = 1;
                foreach (string text in RibbonItems)
                {
                    ribbonItemsTextString += text;
                    if (i++ != RibbonItems.Count)
                    {
                        ribbonItemsTextString += ",";
                    }
                }
                return ribbonItemsTextString;
            }
        }

        public string GroupsText
        {
            get
            {
                int i = 1;
                foreach (string text in Groups)
                {
                    groupText += text;
                    if (i++ != Groups.Count)
                    {
                        groupText += "<br/>";
                    }
                }
                return groupText;
            }
        }
        public string GroupsTextString
        {
            get
            {
                int i = 1;
                foreach (string text in Groups)
                {
                    groupTextString += text;
                    if (i++ != Groups.Count)
                    {
                        groupTextString += ",";
                    }
                }
                return groupTextString;
            }
        }

    }
}
